<?php

//	Author: 	Aris Michail
//	Email:		std03055@di.uoa.gr
//	Purpose: 	Get all pending categories

require_once ("../DB/connection.php");
require_once ("../DB/defines.php");
require_once ("../Frameworks/Objects/user.php");
require_once ("../Frameworks/Objects/category.php");
require_once ("../Frameworks/Objects/attribute.php");

function DB_getPendingCategories()
{

    global $conn;

    // The name of the stored procedure
    $sp_name = "usp_getPendingCategories";

    // The return variable
    $retval;

    // Create a new statement
    $stmt = mssql_init($sp_name, $conn);

    // Bind values
    mssql_bind($stmt, "RETVAL", $retval, SQLINT4, true, false, 1);

    // Execute the statement
    $status = mssql_execute($stmt);
    if ($status)
    {
        $categories = array();
        $i = '0';
        while ($row = mssql_fetch_row($status))
        {
            $cat = new Category();
            $cat->SetId($row[0]);
            $cat->SetName($row[1]);
            $cat->SetOwner($row[2]);
            $cat->SetPrivacy($row[3]);
            //				$cat->SetDateCreated($row[5]);
            $categories[$i] = $cat;
            $i++;
            mssql_next_result($status);
        }
        return $categories;
    }
}

?>